POV-Ray : Newsgroups : povray.general : Issue with function parameters : Issue with function parameters Server Time
2 Nov 2024 15:27:27 EDT (-0400)
  Issue with function parameters  
From: Florian Brucker
Date: 13 Feb 2004 15:29:16
Message: <402d339c@news.povray.org>
The following code produces an unexpected error:

	#local A = 1;
	#local B = function (A) { A }

The error is:

	#local B = function (A <----ERROR

	Parse Error: Expected 'parameter identifier', float function
	'float identifier' found instead

Obviously, it is not allowed to use a function parameter with the same 
name as a previously declared identifier. The documentation does not 
mention this (Or I'm too blind to find it *g*).

Is there a reason for this behaviour?

I came across this error when trying something like this:

	#local A = 1;
	#include "math.inc"

Fails due to

	#declare atan2d = function (A, B) {degrees(atan2(A, B))}

in math.inc. With the current behaviour, I cannot use V, A, B, N, Mn, 
Mx, OMn and OMx as identifier names before including math.inc, because 
they are function parameters of functions declared in math.inc :(
If the current behaviour is really necessary (and I doubt it is), I 
suggest using names like mathinc_V, mathinc_A, etc. for this purpose 
(And yes, I know that this is an ugly way to do it *g*)...

Florian


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.